package min.chapter.five;

import min.chapter.five.board.Article;
import min.chapter.five.board.service.ArticleNotFoundException;
import min.chapter.five.board.service.ReadArticleService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class AnnotationAcquisition {
	public static void main(String[] args) {
		String[] configLocations = new String[] { "min/chapter/five/AnnotationAcquisition.xml" };
		ApplicationContext context = new ClassPathXmlApplicationContext(configLocations);
		ReadArticleService readArticleService = context.getBean("readArticleService", ReadArticleService.class);
		try {
			Article article1 = readArticleService.getArticleAndIncreaseReadCount(1);
			Article article2 = readArticleService.getArticleAndIncreaseReadCount(1);
			System.out.println("article1 == article2 : "+ (article1 == article2));
			readArticleService.getArticleAndIncreaseReadCount(0);
		} catch (ArticleNotFoundException e) {
		}
	}
}